<?
function format_date_for_input($date)
{
	if($date == '0000-00-00' OR $date == NULL)
	{
		return NULL;
	}else{
		$n_date = DateTime::createFromFormat('Y-m-d',$date);
		return $n_date->format('m/d/Y');
	}
};

$genderAttrib = array('male'=>'Male','female'=>'female');
$email = set_value('email',$student->email);
$child_fname = set_value('child_fname',$student->firstname);
$child_mname = set_value('child_mname',$student->lastname);
$child_lname = set_value('child_lname',$student->middlename);
$child_nickname = set_value('child_nickname',$student->nickname);
$child_name_ext = set_value('child_name_ext',$student->name_ext);
$child_placeofbirth = set_value('child_placeofbirth',$student->pob);
$child_bdate = set_value('child_bdate',format_date_for_input($student->dob));
$gender = set_value('gender',$student->gender);
$child_religous = set_value('child_religous',$student->religion);
$child_nationality = set_value('child_nationality',$student->nationality);
$nationality_ssp_number = set_value('nationality_ssp_number',$student->f_ssp_status);
$nationality_visa_status = set_value('nationality_visa_status',$student->f_visa_status);
$nationality_auth_stay = set_value('nationality_auth_stay',$student->f_authorized_stay);
$nationality_passport_no = set_value('nationality_passport_no',$student->f_passport_no);
$nationality_icard_no = set_value('nationality_icard_no',$student->f_i_card_no);
$nationality_date_issued = set_value('nationality_date_issued',format_date_for_input($student->f_date_if_issue));
$child_city_address = set_value('child_city_address',$student->present_address);
$child_telno = set_value('child_telno',$student->contact_no);
$child_adresshowlong = set_value('child_adresshowlong',$student->how_long_living_present_address);
$school_last_attended = set_value('school_last_attended',$student->last_school_name);
$school_level_completed = set_value('school_level_completed',$student->last_school_level);
$school_address = set_value('school_address',$student->last_school_address);
$father_name = set_value('father_name',$student->fathername);
$father_age = set_value('father_age',$student->father_age);
$father_citizenship = set_value('father_citizenship',$student->father_nationality);
$father_educ = set_value('father_educ',$student->father_educ_attain);
$father_talent = set_value('father_talent',$student->father_hobby_talent);
$father_occup = set_value('father_occup',$student->father_occupation);
$father_office_address = set_value('father_office_address',$student->father_office_add);
$father_office_tel = set_value('father_office_tel',$student->father_office_num);
$mother_name = set_value('mother_name',$student->mothername);
$mother_age = set_value('mother_age',$student->mother_age);
$mother_citizenship = set_value('mother_citizenship',$student->mother_nationality);
$mother_educ = set_value('mother_educ',$student->mother_educ_attain);
$mother_talent = set_value('mother_talent',$student->mother_hobby_talent);
$mother_occup = set_value('mother_occup',$student->mother_occupation);
$mother_office_address = set_value('mother_office_address',$student->mother_office_add);
$mother_office_tel = set_value('mother_office_tel',$student->mother_office_num);
$guardian_name = set_value('guardian_name',$student->guardian_name);
$guardian_relation = set_value('guardian_relation',$student->relationship);
$guardian_address = set_value('guardian_address',$student->guardian_address);
$guardian_contact_num = set_value('guardian_contact_num',$student->guardian_contact_no);
$guardian_reason = set_value('guardian_reason',$student->guardian_reason);

$age_first_walked = set_value('',$student->preschool_age_first_walked);
$age_first_talked = set_value('',$student->preschool_age_first_talked);
$w_for_urinate = set_value('',$student->preschool_w_for_urinate);
$w_for_bowel = set_value('',$student->preschool_w_for_bowel);
$w_usual_time = set_value('',$student->preschool_w_usual_time);
$child_dress = set_value('',$student->preschool_child_dress);
$child_undress = set_value('',$student->preschool_child_undress);
$hand_orientation = set_value('',$student->preschool_hand_orientation);
$self_feed = set_value('',$student->preschool_self_feed);
$stayinplace = set_value('',$student->preschool_stayinplace);
$joinothereating = set_value('',$student->preschool_joinothereating);
$food_preferences = set_value('',$student->preschool_food_preferences);
$drink_from_bottle = set_value('',$student->preschool_drink_from_bottle);
$toilet_trained = set_value('',$student->preschool_toilet_trained);
?>



<div>
<div class="alert-box secondary"><h6>Personal Information</h6></div>
<!-- start of Set SECTION-->
<?if(!empty($student)):?>
<div class="">
	<div class="">
		<label>Student ID # and Username:</label>
		<input type="text" value="<?=$student->idno;?>" disabled>
	</div>
	
	<div class="">
		<label>Student Type:</label>
		<input type="text" value="<?=$student->student_type;?>" disabled>
	</div>
	<div class="">
		<label>Grade Level:</label>
		<input type="text" value="<?=$student->level_desc;?>" disabled>
	</div>
</div>
<label class="label">Student Personal Information</label>
<hr>
<form action="<?=site_url('guardian/student_profiles/'.$hid);?>" method="POST" id="update_student_data">
<div class="row">
	<div class="large-4 columns">
		<label class="radius secondary label">Parent's Email Address</label>
		<?=form_error('email');?>
		<input type="email" name="email" value="<?=$email;?>">
	</div>
	
	<div class="large-4 columns">
		<label class="radius secondary label">First Name</label>
		<?=form_error('child_fname');?>
		<input type="text" name="child_fname" value="<?=$child_fname;?>">
	</div>
	<div class="large-4 columns">
		<label class="radius secondary label">Middle Name</label>
		<?=form_error('child_mname');?>
		<input type="text" name="child_mname" value="<?=$child_mname;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label class="radius secondary label">Last Name</label>
		<?=form_error('child_lname');?>
		<input type="text" name="child_lname" value="<?=$child_lname;?>">
	</div>
	<div class="large-4 columns">
		<label class="radius secondary label">Nickname</label>
		<?=form_error('child_nickname');?>
		<input type="text" name="child_nickname" value="<?=$child_nickname;?>">
	</div>
	<div class="large-4 columns">
		<label class="radius secondary label">Name Ext (e.g jr,II,III)</label>
		<?=form_error('child_name_ext');?>
		<input type="text" name="child_name_ext" value="<?=$child_name_ext;?>">
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label class="radius secondary label">Place of Birth</label><?=form_error('child_placeofbirth');?>
		<input type="text" name="child_placeofbirth" value="<?=$child_placeofbirth;?>">
	</div>
	
	<div class="large-4 columns">
		<label class="radius secondary label">Childs Birthdate:</label>
		<?=form_error('child_bdate');?>
		<input type="text" name="child_bdate" class="datepicker" value="<?=$child_bdate;?>">
	</div>
	<div class="large-4 columns">
		<label class="radius secondary label">Gender</label><?=form_error('gender');?>
		<?=form_dropdown('gender', $genderAttrib,$gender);?>
	</div>
</div>
<div class="row">
	<div class="large-4 columns">
		<label class="radius secondary label">Religious Affiliation</label>
		<?=form_error('child_religous');?>
		<input type="text" name="child_religous" value="<?=$child_religous;?>">
	</div>
</div>

	<label class="label">Nationality</label>
	<hr>
	<div>
		<div class="row">
			<div class="large-4 columns">
				<label class="radius secondary label">Nationality</label>
				<input type="text" name="child_nationality" value="<?=$child_nationality;?>">
			</div>
		</div>
		<?=form_error('child_nationality');?>
		<?if($child_nationality !== 'filipino'):?>
		<div><!--start FOR FOREIGN STUDENTS-->
			<label class="label secondary">For Foreign Students ONLY</label>
			<div class="row">
				<div class="large-4 columns">
					<label class="radius secondary label">SSP Number</label>
					<?=form_error('nationality_ssp_number');?>
					<input type="text" name="nationality_ssp_number" value="<?=$nationality_ssp_number;?>">
				</div>
				<div class="large-4 columns">
					<label class="radius secondary label">VISA Status</label>
					<?=form_error('nationality_visa_status');?>
					<input type="text" name="nationality_visa_status" value="<?=$nationality_visa_status;?>">
				</div>
				<div class="large-4 columns">
					<label class="radius secondary label">Authorized Stay</label>
					<?=form_error('nationality_auth_stay');?>
					<input type="text" name="nationality_auth_stay" value="<?=$nationality_auth_stay;?>">
				</div>
			</div>
			<div class="row">
				<div class="large-4 columns">
					<label class="radius secondary label">Passport No.</label>
					<?=form_error('nationality_passport_no');?>
					<input type="text" name="nationality_passport_no" value="<?=$nationality_passport_no;?>">
				</div>
				<div class="large-4 columns">
					<label class="radius secondary label">I-Card No.</label>
					<?=form_error('nationality_icard_no');?>
					<input type="text" name="nationality_icard_no" value="<?=$nationality_icard_no;?>">
				</div>
				<div class="large-4 columns">
					<label class="radius secondary label">Date of Issue</label>
					<?=form_error('nationality_date_issued');?>
					<input type="text" name="nationality_date_issued" class="datepicker" value="<?=$nationality_date_issued;?>">
				</div>
			</div>
		</div><!--END FOR FOREIGN STUDENTS-->
		<?endif;?>
	</div>
	
	<label class="label">Current Address Information</label>
	<hr>
	<div class="row">
		<div  class="large-4 columns">
			<label class="radius secondary label">City Address</label>
			<?=form_error('child_city_address');?>
			<input type="text" name="child_city_address" value="<?=$child_city_address;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Telephone Number</label>
			<?=form_error('child_telno');?>
			<input type="text" name="child_telno" value="<?=$child_telno;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">How Long has Child Lived in This Address?</label>
			<?=form_error('child_adresshowlong');?>
			<input type="text" name="child_adresshowlong" value="<?=$child_adresshowlong;?>">
		</div>
	</div>
	
	<label class="label">Recent School Information</label>
	<hr>
	<div class="row">
		
		<div class="large-4 columns">
			<label class="radius secondary label">School Last Attended</label>
			<?=form_error('school_last_attended');?>
			<input type="text" name="school_last_attended" value="<?=$school_last_attended;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">School Level Completed</label>
			<?=form_error('school_level_completed');?>
			<input type="text" name="school_level_completed" value="<?=$school_level_completed;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Address Of School</label>
			<?=form_error('school_address');?>
			<input type="text" name="school_address" value="<?=$school_address;?>">
		</div>
	</div>
	
	<label class="label">Information About the Father</label>
	<hr>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Full Name</label>
			<?=form_error('father_name');?>
			<input type="text" name="father_name" value="<?=$father_name;?>">
		</div>
		<div class="large-2 columns">
			<label class="radius secondary label">Father's Age</label>
			<?=form_error('father_age');?>
			<input type="text" name="father_age" value="<?=$father_age;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Citizenship:</label>
			<?=form_error('father_citizenship');?>
			<input type="text" name="father_citizenship" value="<?=$father_citizenship;?>">
		</div>
	</div>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Fathers's Educational Attainment</label>
			<?=form_error('father_educ');?>
			<input type="text" name="father_educ" value="<?=$father_educ;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Hobbies/Talent</label>
			<?=form_error('father_talent');?>
			<input type="text" name="father_talent" value="<?=$father_talent;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Occupation/Position</label>
			<?=form_error('father_occup');?>
			<input type="text" name="father_occup" value="<?=$father_occup;?>">
		</div>
	</div>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Office Address</label>
			<?=form_error('father_office_address');?>
			<input type="text" name="father_office_address" value="<?=$father_office_address;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Father's Office Telephone Number</label>
			<?=form_error('father_office_tel');?>
			<input type="text" name="father_office_tel" value="<?=$father_office_tel;?>">
		</div>
		<div class="large-4 columns"></div>
	</div>
	<label class="label">Information about the Mother</label>
	<hr>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Full Name</label>
			<?=form_error('mother_name');?>
			<input type="text" name="mother_name" value="<?=$mother_name;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Age</label>
			<?=form_error('mother_age');?>
			<input type="text" name="mother_age" value="<?=$mother_age;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Citizenship</label>
			<?=form_error('mother_citizenship');?>
			<input type="text" name="mother_citizenship" value="<?=$mother_citizenship;?>">
		</div>
	</div>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Educational Attainment</label>
			<?=form_error('mother_educ');?>
			<input type="text" name="mother_educ" value="<?=$mother_educ;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Hobbies/Talent</label>
			<?=form_error('mother_talent');?>
			<input type="text" name="mother_talent" value="<?=$mother_talent;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Occupation/Position</label>
			<?=form_error('mother_occup');?>
			<input type="text" name="mother_occup" value="<?=$mother_occup;?>">
		</div>
	</div>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Office Address</label>
			<?=form_error('mother_office_address');?>
			<input type="text" name="mother_office_address" value="<?=$mother_office_address;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Mother's Office Telephone Number</label>
			<?=form_error('mother_office_tel');?>
			<input type="text" name="mother_office_tel" value="<?=$mother_office_tel;?>">
		</div>
		<div class="large-4 columns"></div>
	</div>
	<label class="label">Information about the guardian</label>
	<hr>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Guardian's Full Name</label>
			<?=form_error('guardian_name');?>
			<input type="text" name="guardian_name" value="<?=$guardian_name;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Relation To Child</label>
			<?=form_error('guardian_relation');?>
			<input type="text" name="guardian_relation" value="<?=$guardian_relation;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Guardian's Address</label>
			<?=form_error('guardian_address');?>
			<input type="text" name="guardian_address" value="<?=$guardian_address;?>">
		</div>
	</div>
	<div class="row">
		<div class="large-4 columns">
			<label class="radius secondary label">Guardian's Contact Number</label>
			<?=form_error('guardian_contact_num');?>
			<input type="text" name="guardian_contact_num" value="<?=$guardian_contact_num;?>">
		</div>
		<div class="large-4 columns">
			<label class="radius secondary label">Reason for Need of Guardian</label>
			<?=form_error('guardian_reason');?>
			<input type="text" name="guardian_reason" value="<?=$guardian_reason;?>">
		</div>
		<div class="large-4 columns"></div>
	</div>
	<!-- End of personal information -->
	<?if($student->edit == 0 OR isset($imastudent)):?>
		<span><small style="color:#f00">Sorry but this profile is locked and cannot be edited, please contact the school registrar.</small></span></br>
	<?else:?>
	<hr>
	<div>
		<input type="hidden" name="profile_id" value="<?=$student->profile_id;?>">
		<input type="hidden" name="enrollment_id" value="<?=$student->enrollment_id;?>">
		<input type="hidden" name="update_personal_profile" value="true">
		<input type="submit" name="update_personal_profile" value="Update Student Personal Information" class="btn btn-primary">
	</div>
	<?endif;?>
</form>
</div>
<?php else:?>
	<div class="alert-box">
		<h1>Invalid student.</h1>
	</div>
<?php endif;?>